package Transports;

import com.sun.org.apache.xpath.internal.operations.Equals;

public enum TypeTransport {
	AVION("avion"), BATEAU("bateau"), BUS("bus"), TRAIN("train");
	String type;
	
	private TypeTransport(String type){
		this.type = type;
	}
	
    public static TypeTransport toProfil(String profil) {
    	profil = profil.toUpperCase();
    	TypeTransport retour = null;
        try {
            retour = Enum.valueOf(TypeTransport.class, profil);
        } catch (Exception e) {
            retour = TypeTransport.AVION;
        }
        return retour;
    }

	/**
     * Print all valid commands to System.out.
     */
    public static void showAll() {
    	TypeTransport[] tableProfil = TypeTransport.values();
    	int entierafficher = 1;
    	
        for (TypeTransport profil : tableProfil) {
            System.out.println(entierafficher + " : " + profil);
            entierafficher++;
        }
    }
    
    /**
     * Retourner un type transport en fonction de son numero
     * @param num
     * @return
     */
    public static TypeTransport choixTypeTransport(int num){
    	num--;
    	TypeTransport[] tableTypeTransport = TypeTransport.values();
    	return tableTypeTransport[num];
    }
    
	/**
	 * @return Le mot correspondant a son identifiant enum
	 */
	public String toString() {
		return type;
	}
}
